﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace AnguaRPGEngine.Library.Configuration
{
    public class Bookmark
    {
        public string Name;
        public string Page;
        public string OpenCommand;
        public static string AdobeOpenCommand(string page, string fileSpec)
        {
            string pathToAdobeEXE = "";
            if(Directory.Exists(@"C:\Program Files\Adobe"))
            {
                string[] dirs = Directory.GetDirectories(@"C:\Program Files\Adobe");
                foreach(string d in dirs)
                {
                    if (d.Replace(@"C:\Program Files\Adobe\", "").StartsWith("Acrobat"))
                    {
                        pathToAdobeEXE = d;
                        break;
                    }
                }
            }
            if (Directory.Exists(@"C:\Program Files (x86)\Adobe"))
            {
                string[] dirs = Directory.GetDirectories(@"C:\Program Files (x86)\Adobe");
                foreach (string d in dirs)
                {
                    if (d.Replace(@"C:\Program Files (x86)\Adobe\", "").StartsWith("Acrobat"))
                    {
                        pathToAdobeEXE = d;
                        break;
                    }
                }
            }
            if (!pathToAdobeEXE.EndsWith("\\"))
            {
                pathToAdobeEXE += "\\";
            }

            return string.Format("{0}\\Acrobat\\Acrobat.exe /A \"page={1}=OpenActions\" \"{2}\"",
                pathToAdobeEXE, page, fileSpec);

        }
    }
}
